<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>[[.Title]]</title>
    <style>
        :root {
            --primary-color: #2c3e50;
            --accent-color: #3498db;
            --success-color: #27ae60;
            --error-color: #e74c3c;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', system-ui, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 2rem 1rem;
        }

        .container {
            background: rgba(255, 255, 255, 0.95);
            max-width: 600px;
            width: 100%;
            padding: 2.5rem;
            border-radius: 16px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            margin: auto;
            backdrop-filter: blur(10px);
        }

        h1 {
            color: var(--primary-color);
            margin-bottom: 1.5rem;
            font-size: 2.2rem;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .message {
            font-size: 1.1rem;
            line-height: 1.6;
            margin: 1.5rem 0;
            padding: 1.25rem;
            border-radius: 8px;
            animation: fadeIn 0.6s ease;
        }

        .message.success {
            background: #e8f6ef;
            color: var(--success-color);
            border: 2px solid var(--success-color);
        }

        .message.error {
            background: #fdedee;
            color: var(--error-color);
            border: 2px solid var(--error-color);
        }

        .form-group {
            display: flex;
            gap: 1rem;
            margin: 2rem 0;
        }

        input[type="password"] {
            flex: 1;
            padding: 1rem;
            border: 2px solid #e0e0e0;
            border-radius: 10px;
            font-size: 1rem;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        input[type="password"]:focus {
            border-color: var(--accent-color);
            outline: none;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
        }

        button {
            padding: 1rem 2.5rem;
            background: var(--accent-color);
            color: white;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-size: 1rem;
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        button:hover {
            background: #2980b9;
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        .action-link {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            margin-top: 2rem;
            padding: 0.8rem 1.5rem;
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 500;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .action-link:hover {
            background: rgba(44, 62, 80, 0.05);
            color: var(--accent-color);
        }

        @media (max-width: 480px) {
            .container {
                padding: 1.5rem;
                border-radius: 12px;
            }

            h1 {
                font-size: 1.8rem;
            }

            .form-group {
                flex-direction: column;
            }

            button {
                width: 100%;
                padding: 1.2rem;
            }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>[[.Title]]</h1>
        
        [[if .Message]]
        <div class="message [[if .Success]]success[[end]]">
            [[.Message]]
        </div>
        [[end]]

        [[if .ShowForm]]
        <form method="GET">
            <div class="form-group">
                <input type="password" name="password" placeholder="请输入访问密码" required autocomplete="current-password">
                <button type="submit">提交验证</button>
            </div>
        </form>
        [[end]]
    </div>
    
    <script>
        // 自动下载逻辑
        function triggerSecureDownload() {
            // 添加防篡改参数
            const timestamp = Date.now();
            const downloadUrl = `${window.location.pathname}?download=true&t=${timestamp}`;
            
            // 创建临时iframe
            const iframe = document.createElement('iframe');
            iframe.style.display = 'none';
            iframe.src = downloadUrl;
            document.body.appendChild(iframe);
        
            // 显示下载状态
            const progress = document.querySelector('.download-progress');
            let count = 3;
            const timer = setInterval(() => {
                progress.innerHTML = `安全验证通过，${count}秒后开始下载...`;
                if (count-- <= 0) {
                    clearInterval(timer);
                    progress.innerHTML = '正在建立安全连接...';
                    // 添加随机参数防止缓存
                    iframe.src += `&r=${Math.random().toString(36).substr(2)}`;
                }
            }, 1000);
        }
        
        // 初始化检查（修改版）
        window.addEventListener('load', () => {
            const params = new URLSearchParams(window.location.search);
            if (params.has('password') && document.querySelector('.message.success')) {
                // 移除URL中的密码参数
                history.replaceState(null, document.title, window.location.pathname);
                triggerSecureDownload();
            }
        });
    </script>
</body>
</html>